package csoei.bbs.servlets;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import csoei.bbs.Dao.TopicDao;
import csoei.bbs.Dao.UserDao;
public class newtopic extends HttpServlet {
	private static final long serialVersionUID = 1L;public newtopic() {super();}
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {this.doPost(request, response);}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		String username=request.getParameter("username");
		int uid = UserDao.getUidByName(username);
		String cid = request.getParameter("cid");
		String title=request.getParameter("title");
		String content=request.getParameter("content");
		TopicDao.newTopic(cid, uid, title, content);
	}
}
